{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "source": [
    "We made a ton of really nice figures today, and I'd like to let you take home a personalized version as my way of saying thanks for attending. Please run the code cells below to generate your personalized ordering of the Circos plots we made."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "import hashlib\n",
    "import matplotlib.image as mpimg\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "def make_image(name):\n",
    "    \n",
    "    integer = int(hashlib.sha1(bytes(name, 'utf-8')).hexdigest(), 16)\n",
    "    digits = [int(i) for i in list(str(integer))]\n",
    "\n",
    "    # Set the order of images.\n",
    "    order = []\n",
    "    for d in digits:\n",
    "        if d not in order:\n",
    "            order.append(d)\n",
    "    images = {0: 'seventh.png',\n",
    "              1: 'sociopatterns.png',\n",
    "              2: 'physicians.png',\n",
    "              3: 'divvy.png',\n",
    "              4: 'crime-person.png',\n",
    "              5: 'crime-crime.png'}\n",
    "    \n",
    "    imgs_read = []\n",
    "    for i in order:\n",
    "        if i in images.keys():\n",
    "            imgs_read.append(mpimg.imread('images/{0}'.format(images[i])))\n",
    "    # Save the images to disk\n",
    "    plt.imshow(np.hstack(imgs_read))\n",
    "    plt.axis('off')\n",
    "    plt.savefig('images/custom-logo.png', dpi=900, bbox_inches='tight')\n",
    "    plt.savefig('images/custom-logo-small.png', dpi=75, bbox_inches='tight')\n",
    "    print('Thank you for attending, {0}!'.format(name))\n",
    "    print('Your hash-ordered image can be found in at \"images/custom-logo.png\".'.format(name))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "slideshow": {
     "slide_type": "slide"
    }
   },
   "outputs": [],
   "source": [
    "# Change accordingly! :)\n",
    "make_image('Eric Ma')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "celltoolbar": "Slideshow",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  },
  "toc": {
   "colors": {
    "hover_highlight": "#DAA520",
    "navigate_num": "#000000",
    "navigate_text": "#333333",
    "running_highlight": "#FF0000",
    "selected_highlight": "#FFD700",
    "sidebar_border": "#EEEEEE",
    "wrapper_background": "#FFFFFF"
   },
   "moveMenuLeft": true,
   "nav_menu": {
    "height": "12px",
    "width": "252px"
   },
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 4,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": false,
   "widenNotebook": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
